package com.example.hdx.controller;
import com.example.hdx.entity.Product;
import com.example.hdx.mapper.ProductMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/products")
public class ProductController {

    @Autowired//主动注入，作用是把Spring容器创建的对象赋值给下面定义的对象
    ProductMapper productMapper;

    @GetMapping("")
    public List<Product> getAllProducts() {
        List<Product> productsList = productMapper.getAllProducts();
        return productsList;
    }


}